﻿using Microsoft.AspNetCore.Mvc;
using Abp.AspNetCore.Mvc.Authorization;
using Partner.Surround.Controllers;
using Partner.Surround.Sessions;
using Partner.Surround.Web.Views.Shared.Components.SideBarUserArea;
using Abp.Configuration.Startup;
using System.Threading.Tasks;
using Partner.Surround.Configuration;

namespace Partner.Surround.Web.Controllers
{
    [AbpMvcAuthorize]
    public class HomeController : SurroundControllerBase
    {
        private readonly ISessionAppService _sessionAppService;
        private readonly IMultiTenancyConfig _multiTenancyConfig;

        public HomeController(ISessionAppService sessionAppService,
            IMultiTenancyConfig multiTenancyConfig)
        {
            _sessionAppService = sessionAppService;
            _multiTenancyConfig = multiTenancyConfig;
        }

        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public async Task<ActionResult> Index()
        {
            var model = new SideBarUserAreaViewModel
            {
                LoginInformations = await _sessionAppService.GetCurrentLoginInformations(),
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
            };

            return View(model);
        }

        /// <summary>
        /// 控制台
        /// </summary>
        /// <returns></returns>
        public ActionResult Console()
        {
            return View();
        }
    }
}
